package com.gxa.controller;

import com.gxa.domain.entity.PayProject;
import com.gxa.service.Impl.PayProjectServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Controller
@RequestMapping("/payProject")
public class PayProjectController {

    @Autowired
    PayProjectServiceImpl payProjectService;

    @RequestMapping("/findPayProjectById")
    public PayProject findUserById(int payProjectId) {
        return payProjectService.findPayProjectById(payProjectId);
    }

    @RequestMapping(value = "/getAllPayProjects", method = RequestMethod.GET)
    @ResponseBody
    public List<PayProject> getAllPayProjects() {
        return payProjectService.queryAll();
    }

    @RequestMapping(value = "/updatePayProject/{id}", method = RequestMethod.PUT)
    @ResponseBody
    public void updatePayProject(@PathVariable Long id, @RequestBody String columnName) {
        payProjectService.updateById(id, columnName);
    }

    @RequestMapping(value = "/deletePayProject/{id}", method = RequestMethod.DELETE)
    @ResponseBody
    public void deletePayProject(@PathVariable Long id) {
        payProjectService.deleteById(id);
    }

    @RequestMapping(value = "/insertPayProject", method = RequestMethod.POST)
    @ResponseBody
    public void insertPayProject(@RequestBody PayProject payProject) {
        payProjectService.insert(payProject);
    }

    @RequestMapping(value = "/queryPayProjects", method = RequestMethod.GET)
    @ResponseBody
    public List<PayProject> queryPayProjects(@RequestParam("page") int page, @RequestParam("size") int size) {
        return payProjectService.queryPage(page, size);
    }
}
